package control;

import java.io.IOException;
import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;

import javax.annotation.Resource;
import javax.servlet.ServletException;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import javax.servlet.http.HttpSession;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.ResponseBody;
import org.springframework.web.context.request.RequestContextHolder;
import org.springframework.web.context.request.ServletRequestAttributes;
import org.springframework.web.context.request.ServletWebRequest;

import com.alibaba.fastjson.JSONObject;

import dao.CommDAO;

import service.*;
import util.Info;
import util.PageManager;
import util.StrUtil;
import entity.*;
 
@Controller
@RequestMapping("/wallpaper")
public class SysController {
    
     String date = Info.getDateStr();
     CommDAO cdao = new CommDAO();
     CommDAO dao = new CommDAO();
 

     @Autowired 
     public MessagesService messagesService; 
     @Autowired 
     public MixinfoService mixinfoService; 
     @Autowired 
     public PinlunService pinlunService; 
     @Autowired 
     public ResourcesService resourcesService; 
     @Autowired 
     public SysuserService sysuserService; 

     //login.jsp请求处理开始
     @RequestMapping("/login")
     public String login(HttpServletRequest request,HttpServletResponse response,HttpSession session)throws Exception{
    	 String pagerandom = request.getParameter("pagerandom")==null?"":request.getParameter("pagerandom");
			String random = (String)request.getSession().getAttribute("random");
			if(!pagerandom.equals(random)&&request.getParameter("a")!=null)
			{ 
				request.setAttribute("random", "");
				go("/login.jsp", request, response);
			}
			else{ 
			String username = request.getParameter("uname");
			String password = request.getParameter("upass");
			String utype = request.getParameter("utype");
			request.getSession().setAttribute("utype", utype);
			HashMap<String, String> pmap = new HashMap<String, String>();
			pmap.put("tablename","sysuser a ");
			pmap.put("uname",username); 
			pmap.put("upass",password); 
			pmap.put("utype",utype); 
			pmap.put("status","正常");
			pmap.put("orderby"," a.id desc  "); 
				List<HashMap> list = cdao.selectByParam(request,pmap);
				if (list.size() == 1) {
					HashMap map = list.get(0);
					List<HashMap> ulist = cdao.selectByParam(request,pmap); 
					if (ulist.size() == 1&& password.equals(map.get("upass").toString())) { 
							request.getSession().setAttribute("admin", map); 
							gor("/wallpaper/index.jsp", request, response); 
					} else {
						request.setAttribute("error", "");
						go("/login.jsp", request, response);
					}
				} else {
					request.setAttribute("error", "");
					go("/login.jsp", request, response);
				}
			} 
 
     return null;
     }
     //login.jsp请求处理结束
 
 
      //regedit.jsp请求处理开始
      @RequestMapping("/regedit")
      public String regedit(HttpServletRequest request,HttpServletResponse response,HttpSession session)throws Exception{
      HashMap<String,String> user = (HashMap<String,String>)session.getAttribute("admin");
      HashMap<String, String> map = new HashMap<String, String>();
      String uname = request.getParameter("uname")==null?"":request.getParameter("uname");
      String upass = request.getParameter("upass")==null?"":request.getParameter("upass");
      String tname = request.getParameter("tname")==null?"":request.getParameter("tname");
      String sfid = request.getParameter("sfid")==null?"":request.getParameter("sfid");
      String sex = request.getParameter("sex")==null?"":request.getParameter("sex");
      String birth = request.getParameter("birth")==null?"":request.getParameter("birth");
      String tel = request.getParameter("tel")==null?"":request.getParameter("tel");
      String addrs = request.getParameter("addrs")==null?"":request.getParameter("addrs");
      String email = request.getParameter("email")==null?"":request.getParameter("email");
      String savetime = date;
      String filename = request.getParameter("filename")==null?"":request.getParameter("filename");
      String utype = "会员";
      String status = "新会员";
      map.put("uname",uname);
      map.put("upass",upass);
      map.put("tname",tname);
      map.put("sfid",sfid);
      map.put("sex",sex);
      map.put("birth",birth);
      map.put("tel",tel);
      map.put("addrs",addrs);
      map.put("email",email);
      map.put("savetime",savetime);
      map.put("filename",filename);
      map.put("utype",utype);
      map.put("status",status);
      sysuserService.insert(map);
      request.getSession().setAttribute("suc", "suc");
      response.sendRedirect("/wallpaper/regedit.jsp");
      return null;
      }
      //regedit.jsp请求处理结束

      //hysysusertj.jsp请求处理开始
      @RequestMapping("/hysysusertj")
      public String hysysusertj(HttpServletRequest request,HttpServletResponse response,HttpSession session)throws Exception{
      HashMap<String,String> user = (HashMap<String,String>)session.getAttribute("admin");
      HashMap<String, String> map = new HashMap<String, String>();
      String uname = request.getParameter("uname")==null?"":request.getParameter("uname");
      String upass = request.getParameter("upass")==null?"":request.getParameter("upass");
      String tname = request.getParameter("tname")==null?"":request.getParameter("tname");
      String sfid = request.getParameter("sfid")==null?"":request.getParameter("sfid");
      String sex = request.getParameter("sex")==null?"":request.getParameter("sex");
      String birth = request.getParameter("birth")==null?"":request.getParameter("birth");
      String tel = request.getParameter("tel")==null?"":request.getParameter("tel");
      String addrs = request.getParameter("addrs")==null?"":request.getParameter("addrs");
      String email = request.getParameter("email")==null?"":request.getParameter("email");
      String savetime = date;
      String filename = request.getParameter("filename")==null?"":request.getParameter("filename");
      String utype = "会员";
      String status = "正常";
      map.put("uname",uname);
      map.put("upass",upass);
      map.put("tname",tname);
      map.put("sfid",sfid);
      map.put("sex",sex);
      map.put("birth",birth);
      map.put("tel",tel);
      map.put("addrs",addrs);
      map.put("email",email);
      map.put("savetime",savetime);
      map.put("filename",filename);
      map.put("utype",utype);
      map.put("status",status);
      sysuserService.insert(map);
      request.getSession().setAttribute("suc", "suc");
      response.sendRedirect("/wallpaper/admin/hysysusertj.jsp");
      return null;
      }
      //hysysusertj.jsp请求处理结束

     //hysysuserxg.jsp请求处理开始
     @RequestMapping("/hysysuserxg")
     public String hysysuserxg(HttpServletRequest request,HttpServletResponse response,HttpSession session)throws Exception{
     HashMap<String,String> user = (HashMap<String,String>)session.getAttribute("admin");
     String id =  request.getParameter("id");
     HashMap<String, String> map = new HashMap<String, String>();
     String uname = request.getParameter("uname")==null?"":request.getParameter("uname");
     String upass = request.getParameter("upass")==null?"":request.getParameter("upass");
     String tname = request.getParameter("tname")==null?"":request.getParameter("tname");
     String sfid = request.getParameter("sfid")==null?"":request.getParameter("sfid");
     String sex = request.getParameter("sex")==null?"":request.getParameter("sex");
     String birth = request.getParameter("birth")==null?"":request.getParameter("birth");
     String tel = request.getParameter("tel")==null?"":request.getParameter("tel");
     String addrs = request.getParameter("addrs")==null?"":request.getParameter("addrs");
     String email = request.getParameter("email")==null?"":request.getParameter("email");
     String filename = request.getParameter("filename")==null?"":request.getParameter("filename");
     map.put("uname",uname);
     map.put("upass",upass);
     map.put("tname",tname);
     map.put("sfid",sfid);
     map.put("sex",sex);
     map.put("birth",birth);
     map.put("tel",tel);
     map.put("addrs",addrs);
     map.put("email",email);
     map.put("filename",filename);
     map.put("id",id);
     sysuserService.update(map);
     request.getSession().setAttribute("suc", "suc");
     response.sendRedirect("/wallpaper/admin/hysysuserxg.jsp?id="+id+"");
     return null;
     }
     //hysysuserxg.jsp请求处理结束

      //sysusertj.jsp请求处理开始
      @RequestMapping("/sysusertj")
      public String sysusertj(HttpServletRequest request,HttpServletResponse response,HttpSession session)throws Exception{
      HashMap<String,String> user = (HashMap<String,String>)session.getAttribute("admin");
      HashMap<String, String> map = new HashMap<String, String>();
      String uname = request.getParameter("uname")==null?"":request.getParameter("uname");
      String upass = request.getParameter("upass")==null?"":request.getParameter("upass");
      String tname = request.getParameter("tname")==null?"":request.getParameter("tname");
      String sfid = request.getParameter("sfid")==null?"":request.getParameter("sfid");
      String sex = request.getParameter("sex")==null?"":request.getParameter("sex");
      String birth = request.getParameter("birth")==null?"":request.getParameter("birth");
      String tel = request.getParameter("tel")==null?"":request.getParameter("tel");
      String addrs = request.getParameter("addrs")==null?"":request.getParameter("addrs");
      String email = request.getParameter("email")==null?"":request.getParameter("email");
      String savetime = date;
      String filename = request.getParameter("filename")==null?"":request.getParameter("filename");
      String utype = "管理员";
      String status = "正常";
      map.put("uname",uname);
      map.put("upass",upass);
      map.put("tname",tname);
      map.put("sfid",sfid);
      map.put("sex",sex);
      map.put("birth",birth);
      map.put("tel",tel);
      map.put("addrs",addrs);
      map.put("email",email);
      map.put("savetime",savetime);
      map.put("filename",filename);
      map.put("utype",utype);
      map.put("status",status);
      sysuserService.insert(map);
      request.getSession().setAttribute("suc", "suc");
      response.sendRedirect("/wallpaper/admin/sysusertj.jsp");
      return null;
      }
      //sysusertj.jsp请求处理结束

     //sysuserxg.jsp请求处理开始
     @RequestMapping("/sysuserxg")
     public String sysuserxg(HttpServletRequest request,HttpServletResponse response,HttpSession session)throws Exception{
     HashMap<String,String> user = (HashMap<String,String>)session.getAttribute("admin");
     String id =  request.getParameter("id");
     HashMap<String, String> map = new HashMap<String, String>();
     String uname = request.getParameter("uname")==null?"":request.getParameter("uname");
     String upass = request.getParameter("upass")==null?"":request.getParameter("upass");
     String tname = request.getParameter("tname")==null?"":request.getParameter("tname");
     String sfid = request.getParameter("sfid")==null?"":request.getParameter("sfid");
     String sex = request.getParameter("sex")==null?"":request.getParameter("sex");
     String birth = request.getParameter("birth")==null?"":request.getParameter("birth");
     String tel = request.getParameter("tel")==null?"":request.getParameter("tel");
     String addrs = request.getParameter("addrs")==null?"":request.getParameter("addrs");
     String email = request.getParameter("email")==null?"":request.getParameter("email");
     String filename = request.getParameter("filename")==null?"":request.getParameter("filename");
     map.put("uname",uname);
     map.put("upass",upass);
     map.put("tname",tname);
     map.put("sfid",sfid);
     map.put("sex",sex);
     map.put("birth",birth);
     map.put("tel",tel);
     map.put("addrs",addrs);
     map.put("email",email);
     map.put("filename",filename);
     map.put("id",id);
     sysuserService.update(map);
     request.getSession().setAttribute("suc", "suc");
     response.sendRedirect("/wallpaper/admin/sysuserxg.jsp?id="+id+"");
     return null;
     }
     //sysuserxg.jsp请求处理结束

     //psysuserxg.jsp请求处理开始
     @RequestMapping("/psysuserxg")
     public String psysuserxg(HttpServletRequest request,HttpServletResponse response,HttpSession session)throws Exception{
     HashMap<String,String> user = (HashMap<String,String>)session.getAttribute("admin");
     String id =  request.getParameter("id");
     HashMap<String, String> map = new HashMap<String, String>();
     String tname = request.getParameter("tname")==null?"":request.getParameter("tname");
     String sfid = request.getParameter("sfid")==null?"":request.getParameter("sfid");
     String sex = request.getParameter("sex")==null?"":request.getParameter("sex");
     String birth = request.getParameter("birth")==null?"":request.getParameter("birth");
     String tel = request.getParameter("tel")==null?"":request.getParameter("tel");
     String addrs = request.getParameter("addrs")==null?"":request.getParameter("addrs");
     String email = request.getParameter("email")==null?"":request.getParameter("email");
     String filename = request.getParameter("filename")==null?"":request.getParameter("filename");
     map.put("tname",tname);
     map.put("sfid",sfid);
     map.put("sex",sex);
     map.put("birth",birth);
     map.put("tel",tel);
     map.put("addrs",addrs);
     map.put("email",email);
     map.put("filename",filename);
     map.put("id",id);
     sysuserService.update(map);
     request.getSession().setAttribute("suc", "suc");
     response.sendRedirect("/wallpaper/admin/psysuserxg.jsp?id="+id+"");
     return null;
     }
     //psysuserxg.jsp请求处理结束

     //mixinfoxg.jsp请求处理开始
     @RequestMapping("/mixinfoxg")
     public String mixinfoxg(HttpServletRequest request,HttpServletResponse response,HttpSession session)throws Exception{
     HashMap<String,String> user = (HashMap<String,String>)session.getAttribute("admin");
     String id =  request.getParameter("id");
     HashMap<String, String> map = new HashMap<String, String>();
     String content = request.getParameter("content")==null?"":request.getParameter("content");
     content = content.replaceAll("'"," ");
     map.put("content",content);
     map.put("id",id);
     mixinfoService.update(map);
     request.getSession().setAttribute("suc", "suc");
     response.sendRedirect("/wallpaper/admin/mixinfoxg.jsp?id="+id+"");
     return null;
     }
     //mixinfoxg.jsp请求处理结束
 
      //tmixinfotj.jsp请求处理开始
      @RequestMapping("/tmixinfotj")
      public String tmixinfotj(HttpServletRequest request,HttpServletResponse response,HttpSession session)throws Exception{
      HashMap<String,String> user = (HashMap<String,String>)session.getAttribute("admin");
      HashMap<String, String> map = new HashMap<String, String>();
      String content = request.getParameter("content")==null?"":request.getParameter("content");
      content = content.replaceAll("'"," ");
      map.put("content",content);
      mixinfoService.insert(map);
      request.getSession().setAttribute("suc", "suc");
      response.sendRedirect("/wallpaper/admin/tmixinfotj.jsp");
      return null;
      }
      //tmixinfotj.jsp请求处理结束

     //tmixinfoxg.jsp请求处理开始
     @RequestMapping("/tmixinfoxg")
     public String tmixinfoxg(HttpServletRequest request,HttpServletResponse response,HttpSession session)throws Exception{
     HashMap<String,String> user = (HashMap<String,String>)session.getAttribute("admin");
     String id =  request.getParameter("id");
     HashMap<String, String> map = new HashMap<String, String>();
     String mtitle = request.getParameter("mtitle")==null?"":request.getParameter("mtitle");
     String cotitle = request.getParameter("cotitle")==null?"":request.getParameter("cotitle");
     String filename = request.getParameter("filename")==null?"":request.getParameter("filename");
     map.put("mtitle",mtitle);
     map.put("cotitle",cotitle);
     map.put("filename",filename);
     map.put("id",id);
     mixinfoService.update(map);
     request.getSession().setAttribute("suc", "suc");
     response.sendRedirect("/wallpaper/admin/tmixinfoxg.jsp?id="+id+"");
     return null;
     }
     //tmixinfoxg.jsp请求处理结束

     //messagesxg.jsp请求处理开始
     @RequestMapping("/messagesxg")
     public String messagesxg(HttpServletRequest request,HttpServletResponse response,HttpSession session)throws Exception{
     HashMap<String,String> user = (HashMap<String,String>)session.getAttribute("admin");
     String id =  request.getParameter("id");
     HashMap<String, String> map = new HashMap<String, String>();
     String recont = request.getParameter("recont")==null?"":request.getParameter("recont");
     map.put("recont",recont);
     map.put("id",id);
     messagesService.update(map);
     request.getSession().setAttribute("suc", "suc");
     response.sendRedirect("/wallpaper/admin/messagesxg.jsp?id="+id+"");
     return null;
     }
     //messagesxg.jsp请求处理结束

      //tresourcestj.jsp请求处理开始
      @RequestMapping("/tresourcestj")
      public String tresourcestj(HttpServletRequest request,HttpServletResponse response,HttpSession session)throws Exception{
      HashMap<String,String> user = (HashMap<String,String>)session.getAttribute("admin");
      HashMap<String, String> map = new HashMap<String, String>();
      String title = request.getParameter("title")==null?"":request.getParameter("title");
      String stype = request.getParameter("stype")==null?"":request.getParameter("stype");
      String ipush = request.getParameter("ipush")==null?"":request.getParameter("ipush");
      String savetime = date;
      String filename = request.getParameter("filename")==null?"":request.getParameter("filename");
      String docname2 = request.getParameter("docname2")==null?"":request.getParameter("docname2");
      String docname3 = request.getParameter("docname3")==null?"":request.getParameter("docname3");
      String content = request.getParameter("content")==null?"":request.getParameter("content");
      content = content.replaceAll("'"," ");
      String uname = Info.getUser(request).get("uname").toString();
      map.put("title",title);
      map.put("stype",stype);
      map.put("ipush",ipush);
      map.put("savetime",savetime);
      map.put("filename",filename);
      map.put("docname2",docname2);
      map.put("docname3",docname3);
      map.put("content",content);
      map.put("uname",uname);
      resourcesService.insert(map);
      request.getSession().setAttribute("suc", "suc");
      response.sendRedirect("/wallpaper/admin/tresourcestj.jsp");
      return null;
      }
      //tresourcestj.jsp请求处理结束

     //tresourcesxg.jsp请求处理开始
     @RequestMapping("/tresourcesxg")
     public String tresourcesxg(HttpServletRequest request,HttpServletResponse response,HttpSession session)throws Exception{
     HashMap<String,String> user = (HashMap<String,String>)session.getAttribute("admin");
     String id =  request.getParameter("id");
     HashMap<String, String> map = new HashMap<String, String>();
     String title = request.getParameter("title")==null?"":request.getParameter("title");
     String stype = request.getParameter("stype")==null?"":request.getParameter("stype");
     String ipush = request.getParameter("ipush")==null?"":request.getParameter("ipush");
     String filename = request.getParameter("filename")==null?"":request.getParameter("filename");
     String docname2 = request.getParameter("docname2")==null?"":request.getParameter("docname2");
     String docname3 = request.getParameter("docname3")==null?"":request.getParameter("docname3");
     String content = request.getParameter("content")==null?"":request.getParameter("content");
     content = content.replaceAll("'"," ");
     map.put("title",title);
     map.put("stype",stype);
     map.put("ipush",ipush);
     map.put("filename",filename);
     map.put("docname2",docname2);
     map.put("docname3",docname3);
     map.put("content",content);
     map.put("id",id);
     resourcesService.update(map);
     request.getSession().setAttribute("suc", "suc");
     response.sendRedirect("/wallpaper/admin/tresourcesxg.jsp?id="+id+"");
     return null;
     }
     //tresourcesxg.jsp请求处理结束
 

 

      //resourcestj.jsp请求处理开始
      @RequestMapping("/resourcestj")
      public String resourcestj(HttpServletRequest request,HttpServletResponse response,HttpSession session)throws Exception{
      HashMap<String,String> user = (HashMap<String,String>)session.getAttribute("admin");
      HashMap<String, String> map = new HashMap<String, String>();
      String title = request.getParameter("title")==null?"":request.getParameter("title");
      String stype = request.getParameter("stype")==null?"":request.getParameter("stype");
      String ipush = request.getParameter("ipush")==null?"":request.getParameter("ipush");
      String savetime = date;
      String filename = request.getParameter("filename")==null?"":request.getParameter("filename");
      String content = request.getParameter("content")==null?"":request.getParameter("content");
      content = content.replaceAll("'"," ");
      String uname = Info.getUser(request).get("uname").toString();
      map.put("title",title);
      map.put("stype",stype);
      map.put("ipush",ipush);
      map.put("savetime",savetime);
      map.put("filename",filename);
      map.put("content",content);
      map.put("uname",uname);
      resourcesService.insert(map);
      request.getSession().setAttribute("suc", "suc");
      response.sendRedirect("/wallpaper/admin/resourcestj.jsp");
      return null;
      }
      //resourcestj.jsp请求处理结束

     //resourcesxg.jsp请求处理开始
     @RequestMapping("/resourcesxg")
     public String resourcesxg(HttpServletRequest request,HttpServletResponse response,HttpSession session)throws Exception{
     HashMap<String,String> user = (HashMap<String,String>)session.getAttribute("admin");
     String id =  request.getParameter("id");
     HashMap<String, String> map = new HashMap<String, String>();
     String title = request.getParameter("title")==null?"":request.getParameter("title");
     String stype = request.getParameter("stype")==null?"":request.getParameter("stype");
     String ipush = request.getParameter("ipush")==null?"":request.getParameter("ipush");
     String filename = request.getParameter("filename")==null?"":request.getParameter("filename");
     String content = request.getParameter("content")==null?"":request.getParameter("content");
     content = content.replaceAll("'"," ");
     map.put("title",title);
     map.put("stype",stype);
     map.put("ipush",ipush);
     map.put("filename",filename);
     map.put("content",content);
     map.put("id",id);
     resourcesService.update(map);
     request.getSession().setAttribute("suc", "suc");
     response.sendRedirect("/wallpaper/admin/resourcesxg.jsp?id="+id+"");
     return null;
     }
     //resourcesxg.jsp请求处理结束

      //resourcescx.jsp请求处理开始
      @RequestMapping("/resourcescx")
      public String resourcescx(HttpServletRequest request,HttpServletResponse response,HttpSession session)throws Exception{
      String ptitle = request.getParameter("title")==null?"":request.getParameter("title"); 
      String pstype = request.getParameter("stype")==null?"":request.getParameter("stype"); 
      String puname = request.getParameter("uname")==null?"":request.getParameter("uname"); 
      String startsavetime = request.getParameter("startsavetime")==null?"":request.getParameter("startsavetime"); 
      String endsavetime = request.getParameter("endsavetime")==null?"":request.getParameter("endsavetime"); 
      HashMap mmm = new HashMap(); 
      HashMap<String,String> selectmap = new HashMap();
      HashMap<String,String> selectymap = new HashMap();
      HashMap<String,String> selectbmap = new HashMap();
      selectmap.put("title","");  
      selectmap.put("stype","");  
      selectmap.put("uname","");  
      if(!startsavetime.equals("")){  
      selectbmap.put("startsavetime",">=");  
      mmm.put("startsavetime",startsavetime);  
      }  
      if(!endsavetime.equals("")){  
      selectbmap.put("endsavetime","<=");  
      mmm.put("endsavetime",endsavetime);  
      }  
      String sql = Info.selectBuild3("resources",selectmap,selectymap,selectbmap,request) ;
      String url = "resourcescx.jsp?1=1&title="+ptitle+"&stype="+pstype+"&uname="+puname+"&savetime="+startsavetime+"&savetime="+endsavetime+""; 
      ArrayList<HashMap> list = PageManager.getPages(url,5, sql, request ); 
      mmm.put("title",ptitle); 
      mmm.put("stype",pstype); 
      mmm.put("uname",puname); 
      mmm.put("savetime",startsavetime); 
      mmm.put("savetime",endsavetime); 
      request.setAttribute("smmm", mmm); 
      request.setAttribute("slist", list); 
      return null;
      }
      //resourcescx.jsp请求处理结束

      //xresourcestj.jsp请求处理开始
      @RequestMapping("/xresourcestj")
      public String xresourcestj(HttpServletRequest request,HttpServletResponse response,HttpSession session)throws Exception{
      HashMap<String,String> user = (HashMap<String,String>)session.getAttribute("admin");
      HashMap<String, String> map = new HashMap<String, String>();
      String title = request.getParameter("title")==null?"":request.getParameter("title");
      String stype = request.getParameter("stype")==null?"":request.getParameter("stype");
      String ipush = request.getParameter("ipush")==null?"":request.getParameter("ipush");
      String savetime = date;
      String filename = request.getParameter("filename")==null?"":request.getParameter("filename");
      String content = request.getParameter("content")==null?"":request.getParameter("content");
      content = content.replaceAll("'"," ");
      String uname = Info.getUser(request).get("uname").toString();
      map.put("title",title);
      map.put("stype",stype);
      map.put("ipush",ipush);
      map.put("savetime",savetime);
      map.put("filename",filename);
      map.put("content",content);
      map.put("uname",uname);
      resourcesService.insert(map);
      request.getSession().setAttribute("suc", "suc");
      response.sendRedirect("/wallpaper/admin/xresourcestj.jsp");
      return null;
      }
      //xresourcestj.jsp请求处理结束

     //xresourcesxg.jsp请求处理开始
     @RequestMapping("/xresourcesxg")
     public String xresourcesxg(HttpServletRequest request,HttpServletResponse response,HttpSession session)throws Exception{
     HashMap<String,String> user = (HashMap<String,String>)session.getAttribute("admin");
     String id =  request.getParameter("id");
     HashMap<String, String> map = new HashMap<String, String>();
     String title = request.getParameter("title")==null?"":request.getParameter("title");
     String stype = request.getParameter("stype")==null?"":request.getParameter("stype");
     String ipush = request.getParameter("ipush")==null?"":request.getParameter("ipush");
     String filename = request.getParameter("filename")==null?"":request.getParameter("filename");
     String content = request.getParameter("content")==null?"":request.getParameter("content");
     content = content.replaceAll("'"," ");
     map.put("title",title);
     map.put("stype",stype);
     map.put("ipush",ipush);
     map.put("filename",filename);
     map.put("content",content);
     map.put("id",id);
     resourcesService.update(map);
     request.getSession().setAttribute("suc", "suc");
     response.sendRedirect("/wallpaper/admin/xresourcesxg.jsp?id="+id+"");
     return null;
     }
     //xresourcesxg.jsp请求处理结束

      //xresourcescx.jsp请求处理开始
      @RequestMapping("/xresourcescx")
      public String xresourcescx(HttpServletRequest request,HttpServletResponse response,HttpSession session)throws Exception{
      String ptitle = request.getParameter("title")==null?"":request.getParameter("title"); 
      String pstype = request.getParameter("stype")==null?"":request.getParameter("stype"); 
      String startsavetime = request.getParameter("startsavetime")==null?"":request.getParameter("startsavetime"); 
      String endsavetime = request.getParameter("endsavetime")==null?"":request.getParameter("endsavetime"); 
      HashMap mmm = new HashMap(); 
      HashMap<String,String> selectmap = new HashMap();
      HashMap<String,String> selectymap = new HashMap();
      HashMap<String,String> selectbmap = new HashMap();
      selectmap.put("title","");  
      selectmap.put("stype","");  
      if(!startsavetime.equals("")){  
      selectbmap.put("startsavetime",">=");  
      mmm.put("startsavetime",startsavetime);  
      }  
      if(!endsavetime.equals("")){  
      selectbmap.put("endsavetime","<=");  
      mmm.put("endsavetime",endsavetime);  
      }  
      selectymap.put("uname",Info.getUser(request).get("uname").toString());  
      String sql = Info.selectBuild3("resources",selectmap,selectymap,selectbmap,request) ;
      String url = "xresourcescx.jsp?1=1&title="+ptitle+"&stype="+pstype+"&savetime="+startsavetime+"&savetime="+endsavetime+""; 
      ArrayList<HashMap> list = PageManager.getPages(url,5, sql, request ); 
      mmm.put("title",ptitle); 
      mmm.put("stype",pstype); 
      mmm.put("savetime",startsavetime); 
      mmm.put("savetime",endsavetime); 
      request.setAttribute("smmm", mmm); 
      request.setAttribute("slist", list); 
      return null;
      }
      //xresourcescx.jsp请求处理结束

//--业务层代码块结束--
 
    public void go(String url,HttpServletRequest request, HttpServletResponse response)
	{
	try {
		request.getRequestDispatcher(url).forward(request, response);
	} catch (Exception e) {
		e.printStackTrace();
	}
	}
	
	public void gor(String url,HttpServletRequest request, HttpServletResponse response)
	{
		try {
			response.sendRedirect(url);
		} catch (Exception e) {
			// TODO Auto-generated catch block
			e.printStackTrace();
		}
	
	}
    
}